package com.k8s.base.domain;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.Objects;

/**
 * 文件生成设置
 */
@Entity
@Table(name = "generate_file_storage_setting")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class GenerateFileStorageSetting implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 文件源
     */
    @NotNull
    @Size(max = 200)
    @Column(name = "source", length = 200, nullable = false)
    private String source;

    /**
     * 文件源名称
     */
    @Size(max = 200)
    @Column(name = "source_name", length = 200)
    private String sourceName;

    /**
     * 过期时间 为0 不过期
     */
    @NotNull
    @Column(name = "expire_time", nullable = false)
    private Integer expireTime;

    @NotNull
    @Column(name = "save_last_one", nullable = false)
    private Boolean saveLastOne;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getSource() {
        return source;
    }

    public GenerateFileStorageSetting source(String source) {
        this.source = source;
        return this;
    }

    public void setSource(String source) {
        this.source = source;
    }

    public String getSourceName() {
        return sourceName;
    }

    public GenerateFileStorageSetting sourceName(String sourceName) {
        this.sourceName = sourceName;
        return this;
    }

    public void setSourceName(String sourceName) {
        this.sourceName = sourceName;
    }

    public Integer getExpireTime() {
        return expireTime;
    }

    public GenerateFileStorageSetting expireTime(Integer expireTime) {
        this.expireTime = expireTime;
        return this;
    }

    public void setExpireTime(Integer expireTime) {
        this.expireTime = expireTime;
    }

    public Boolean isSaveLastOne() {
        return saveLastOne;
    }

    public void setSaveLastOne(Boolean saveLastOne) {
        this.saveLastOne = saveLastOne;
    }

    public GenerateFileStorageSetting saveLastOne(Boolean saveLastOne) {
        this.saveLastOne = saveLastOne;
        return this;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        GenerateFileStorageSetting generateFileStorageSetting = (GenerateFileStorageSetting) o;
        if (generateFileStorageSetting.id == null || id == null) {
            return false;
        }
        return Objects.equals(id, generateFileStorageSetting.id);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(id);
    }

    @Override
    public String toString() {
        return "GenerateFileStorageSetting{" +
            "id=" + id +
            ", source='" + source + "'" +
            ", sourceName='" + sourceName + "'" +
            ", expireTime='" + expireTime + "'" +
            '}';
    }
}
